<div class="pageHeader">
<form id="pagerForm" action="__URL__" method="post">
  
  <input type="hidden" name="mobile" value="{$_REQUEST.mobile}"/>
  <input type="hidden" name="orderField" value="{$_REQUEST.orderField}">
  <input type="hidden" name="orderDirection" value="{$_REQUEST.orderDirection}">
  <input type="hidden" name="pageNum" value="{$_REQUEST['pageNum']|default=1}"/>
  <input type="hidden" name="numPerPage" value="{$numPerPage}"/>
   
    
</form>
<form onsubmit="return navTabSearch(this);"  class="form-inline" action="__URL__" method="post">
                                  <div class="form-group">
                                      <label>手机卡号：</label><input type="text" value="{$_REQUEST.mobile}" name="mobile" class="form-control" size="15" />
                                  </div>
                                  <if condition="$ausers['dengji'] neq 4">
                                  <div class="form-group">
                                      <label>是否分配：</label>
                                      <select name="state" id="state"  data-container="body"  class="selectpicker show-tick" data-style="btn-default btn-sm" data-width="auto">
                                        <option value="">请选择</option>
                                        <option value="0">未分配</option>
                                        <option value="1">已分配</option>
                                      </select>
                                  </div>
                                  <div class="form-group">
                                    <div class="col-sm-5">
                                          <select name="user_id" id="user_id"  data-container="body"  class="selectpicker show-tick" data-style="btn-default btn-sm" data-width="auto">
                                                <option value="">请选择下级用户查询</option>
                                                <volist name="kauser" id="so">
                                                  <option value="{$so.id}">{$so.nickname}</option>
                                                </volist>
                                          </select>
                                    </div>
                                  </div>
                                  </if>
                                  <div class="form-group">
                                     
                                  </div>

                                  <div class="form-group">
                                      <button type="submit" class="btn btn-warning btn-sm"><i class="icon-search"></i> 查询</button>
                                     <a class="btn btn-primary btn-sm" href="javascript:navTab.reload('', {clearQuery:true});"><i class="icon-undo"></i> 清空查询</a>
                                     <if condition="session('userid') eq 1">
                                      <a href="__URL__/add" target="dialog" rel="useradd" mask="true" minable="true" width="500" height="400" class="btn btn-primary btn-sm"><i class="icon-plus"></i> 新增</a>
                                      </if>
                                     <if condition="$ausers['dengji'] neq 4">
                                      <div class="form-group">
                                        <div class="col-sm-5">
                                              <select name="position" id="kauser"  data-container="body"  class="selectpicker show-tick" data-style="btn-default btn-sm" data-width="auto">
                                                    <option value="fen">请选择用户进行分配</option>
                                                    <volist name="kauser" id="so">
                                                    <!--   <option value="{$so.id}" data="{$so.type}" <if condition="$so['id'] eq $info['position']">selected</if> >{$so.title}</option> -->
                                                      <option value="{$so.id}">{$so.nickname}</option>
                                                    </volist>
                                              </select>
                                        </div>
                                      </div>
                                      <a href="__URL__/allot" target="checkedAjaxTodo" idname="ids"><button type="button" class="btn btn-primary btn-sm" style="background: #53BEE6;border:1px solid #53BEE6;"><i class="icon-search"></i> 分配</button></a>

                                      <a><button type="button" onclick="outbiao()" class="btn btn-primary btn-sm" style="background: #53BEE6;border:1px solid #53BEE6;"><i class="icon-search"></i> 导出筛选</button></a>
                                     </if>
                                     <if condition="$ausers['dengji'] eq 4">
                                  <div class="form-group">
                                     <a width="500" height="400" class="btn btn-primary btn-sm"> 短信{$ausers.smssum}条可用</a>
                                  </div>
                                    </if>
                                  </div>
                                <if condition="session('userid') eq 1">
                                 <div class="pull-right btn-group">
                                  <button data-toggle="dropdown" class="btn btn-success dropdown-toggle btn-sm" type="button"><i class="icon-list"></i> 批量操作<span class="caret"></span></button>
                                  <ul role="menu" class="dropdown-menu">
                                  <div class="log-arrow-up"></div>
                                      <li><a href="__URL__/outxls/ids/all" target="dwzExport">导出<span style="color: green;">全部</span></a></li>
                                      <li><a href="__URL__/outxls" target="checkedExport" idname="ids">导出<span style="color: red;">选中</span></a></li>
                                      <li class="divider"></li>
                                      <li><a href="__URL__/selectedDelete"  title="确定要删除选中信息吗？" target="checkedAjaxTodo" idname="ids">删除选中</a></li>
                                  </ul>
                                </div>
                                </if>
</form>

    
</div>



<div class="pageContent">
    <table class="j-table" width="100%" layoutH="95">
        <thead>
            <tr>
                <th>编号</th>
                <th>手机卡号</th>
                <th>批次号</th>
                <if condition="$ausers['dengji'] eq 1">
                  <th>下级用户</th>
                </if>
                <if condition="$ausers['dengji'] eq 2">
                  <th>下级用户</th>
                  <th>下级用户</th>
                </if>
                <if condition="$ausers['dengji'] eq 3">
                  <th>下级用户</th>
                  <th>下级用户</th>
                </if>
                <if condition="$ausers['dengji'] eq 4">
                  <th>下级用户</th>
                </if>
                <th class="orderby <eq name="order" value="create_time">{$sortImg}</eq>" orderField="create_time">添加时间</th>
                <th class="orderby <eq name="order" value="create_time">{$sortImg}</eq>" orderField="fenpei_time">分配时间</th> 
                <th>发送短信</th>
                <th width="30"><input type="checkbox" class="checkboxCtrl j-icheck" group="ids"></th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>

           <volist id="vo" name="list">
            <tr> 
                <td>{$vo['id']}</td>
                <td>{$vo['mobile']}</td>
                <td>{$vo['p_sn']}</td>
                <if condition="$ausers['dengji'] eq 1">
                  <td>{$vo['nickname']}</td>
                </if>
                <if condition="$ausers['dengji'] eq 2">
                  <td>{$vo['nickname']}</td>
                  <td>{$vo['sanname']}</td>
                </if>
                <if condition="$ausers['dengji'] eq 3">
                  <td>{$vo['sanname']}</td>
                  <td>{$vo['siname']}</td>
                </if>
                <if condition="$ausers['dengji'] eq 4">
                  <td>{$vo['siname']}</td>
                </if>
                <td>{$vo['time']}</td>
                <td>{$vo['fenpei_time']}</td>
                <td>
                  <div class="btn-group  btn-group-xs">
                  <input type="hidden" id="mobile{$vo['id']}" value="{$vo['mobile']}">

                  <if condition="$ausers['dengji'] eq 1">
                    <input type="hidden" id="user_id{$vo['id']}" value="{$vo['user_id']}">

                  <elseif condition="$ausers['dengji'] eq 2" />
                    <input type="hidden" id="user_id{$vo['id']}" value="{$vo['user_id']}">

                  <elseif condition="$ausers['dengji'] eq 3" />
                    <input type="hidden" id="user_id{$vo['id']}" value="{$vo['san_id']}">

                  <elseif condition="$ausers['dengji'] eq 4" />
                    <input type="hidden" id="user_id{$vo['id']}" value="{$vo['san_id']}">
                  </if>
                  
                  <if condition="$vo['fa_state'] eq 1">
                    <a class="btn btn-primary" onclick="datamobile({$vo['id']},{$vo['user_id']})"><i class="icon-edit"></i>已发送</a>
                  <else />
                    <if condition="$vo['user_id'] neq 0">
                    <a class="btn btn-primary" onclick="datamobile({$vo['id']},{$vo['user_id']})"><i class="icon-edit"></i>发送</a>
                    </if>
                  </if>
                  </div>
                </td>
                <td><if condition="$ausers['dengji'] neq 4"><input type="checkbox" name="ids" class="j-icheck" value="{$vo['id']}"></if></td>
                <td>
                <if condition="session('userid') eq 1">
                <div class="btn-group  btn-group-xs">
                 <a href="__URL__/edit/id/{$vo['id']}/navTabId/{:CONTROLLER_NAME}"   class="btn btn-primary" target="dialog"  mask="true"  width="500" height="400" ><i class="icon-edit"></i> 编辑</a>
                    <a href="__URL__/foreverdelete/id/{$vo['id']}/navTabId/{:CONTROLLER_NAME}" class="btn btn-danger" target="ajaxTodo" title="确定要删除该行信息吗？"><i style="font-size:12px;" class="icon-trash"></i> 删除</a>
                    </div>
                  </if>
                </td>
            </tr>
            
          </volist>
        </tbody>
    </table>
    <div class="panelBar">
        <div class="pages pull-left">
            
            <span>共 {$totalCount} 条</span>
        </div>

   
        <div class="pagination-box" targettype="navTab" totalCount="{$totalCount}" numPerPage="{$numPerPage}" pageNumShown="10" currentPage="{$currentPage}">
        </div>
    </div>
</div>
<!-- <div id="alertMsgBoxs" style="display: block;" class="modal" style="top: 0px;"><div class="modal-dialog"><div class="modal-content  confirm"><div class="modal-header"><h4 class="modal-title"><i class="icon-question-sign"></i> 确认提示</h4></div><div class="modal-body">确定要删除该行信息吗？</div><div class="modal-footer"><button class="btn btn-sm btn-default" rel="callback" onclick="alertMsg.close()" type="button">确定</button><button class="btn btn-sm btn-default" rel="" onclick="alertMsg.close()" type="button">取消</button></div></div></div></div> -->

<!-- 弹窗 start -->
<style type="text/css">
  .closebox{
        background-color: #ff6c60;
        border-color: #ff6c60;
        color: #FFFFFF;
        padding: 5px 10px;
        font-size: 12px;
        line-height: 1.5;
        border-radius: 3px;
        display: inline-block;
        margin-bottom: 0;
        font-weight: normal;
        text-align: center;
        vertical-align: middle;
        touch-action: manipulation;
        cursor: pointer;
        background-image: none;
        border: 1px solid transparent;
        white-space: nowrap;
        padding: 4px 12px;
        font-size: 14px;
        line-height: 1.42857143;
        border-radius: 4px;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
  }
  .selectbox{
    width: 100%;
    padding:4px;
  }
  .selectbox select{
    display: block;
    width: 62%;
    padding: 4px;
    border-radius: 3px;
  }
</style>
<div class="dialog dialogbox" style="top: 50px; left: 518px; z-index: 1000; width: 502px;overflow: hidden;position: fixed;display: none;"><div class="dialogHeader" onselectstart="return false;" oncopy="return false;" onpaste="return false;" oncut="return false;"><div class="dialogHeader_r"><div class="dialogHeader_c"><a class="close" href="javascript:closebox()" title="关闭"><i class="icon-remove-sign"></i></a><a class="maximize" href="#maximize" title="最大化"><i class="icon-plus-sign"></i></a><a class="restore" href="#restore" title="还原"><i class="icon-share-sign"></i></a><a class="minimize" href="javascript:void(0)" title="最小化" style="display: none;"><i class="icon-minus-sign"></i></a><h1> 发送</h1></div></div></div><div class="dialogContent layoutBox unitBox" style="height: 372px;position: relative;"><div class="pageContent" style="width: 486px;position: relative;height: 360px;">
    <div class="pageForm form-validate">

        <!-- <div class="pageFormContent form-horizontal" layouth="60" tabindex="5002" style="height: 326px; overflow: hidden; outline: none;"> -->
            <div class="form-group"
            style="margin-top: 20px;">
                <label for="j_sn" class="control-label col-sm-2">短信内容：</label>
                <textarea name="mobile" id="content" class="form-control validate[required] textInput" rows="8" cols="30" style="width: 300px;"></textarea>
            </div>
            <input type="hidden" value="20180809095014" name="time">
    <!-- </div> -->
          <div class="selectbox">
            <label for="j_sn" class="control-label col-sm-2">目的码：</label>
            <select name="selectname" id="selecteds">
              
            </select>
          </div>
    <div class="formBar" style="position: absolute;bottom: 0;left: 0;width:100%;">
            <ul>
                <li><button type="button" class="btn btn-default btn-sm" onclick="savedata()">发送</button></li>
                <li><button type="button" class="closebox" onclick="closebox()">取消</button></li>
            </ul>
    </div>
    </div>
</div></div><div class="dialogFooter"><div class="dialogFooter_r"><div class="dialogFooter_c"></div></div></div><div class="resizable_h_l" tar="nw"></div><div class="resizable_h_r" tar="ne"></div><div class="resizable_h_c" tar="n"></div><div class="resizable_c_l" tar="w" style="height:300px;"></div><div class="resizable_c_r" tar="e" style="height:300px;"></div><div class="resizable_f_l" tar="sw"></div><div class="resizable_f_r" tar="se"></div><div class="resizable_f_c" tar="s"></div><div id="ascrail2002" class="nicescroll-rails" style="width: 3px; z-index: 1000; background: rgb(64, 64, 64); cursor: default; position: absolute; top: 34px; left: 493px; height: 326px; opacity: 0; display: none;"><div style="position: relative; top: 0px; float: right; width: 3px; height: 0px; background-color: rgb(204, 204, 204); background-clip: padding-box;"></div></div><div id="ascrail2002-hr" class="nicescroll-rails" style="height: 3px; z-index: 1000; background: rgb(64, 64, 64); top: 357px; left: 6px; position: absolute; cursor: default; opacity: 0; display: none;"><div style="position: relative; top: 0px; height: 3px; width: 0px; background-color: rgb(204, 204, 204); background-clip: padding-box; left: 0px;"></div></div></div>

<!-- 弹窗 end   -->

<script type="text/javascript">
  function closebox(){
    $('.dialogbox').hide();
  }   
      var ids = '';
      function datamobile(id,user_id){
        ids=id
        //ajax获取目的码
        $.ajax({
          url:"__URL__/mudima",
          type:'post',
          cache:false,
          dataType:'JSON',
          timeout: 10000,
          data:{"user_id":user_id},
          success:function(dete){
            // console.log(dete)
              if (dete == 'false') {
                var count = dete.length;
                var m = '';
                for (var i = 0; i < count; i++) {
                    m +='<option value="'+dete[i]['codeNo']+'">没有目的码</option>';
                }
                $('#selecteds').html(m);
              }else{
                var count = dete.length;
                var m = '';
                for (var i = 0; i < count; i++) {
                    m +='<option value="'+dete[i]['codeNo']+'">'+dete[i]['content']+'-'+dete[i]['codeNo']+'</option>';
                }
                $('#selecteds').html(m);
              }
              
            }
        }) 
        $('.dialogbox').show();
      }
  
      function savedata(){
        var user_id = $('#user_id'+ids).val();
        var mobile  = $('#mobile'+ids).val();
        // var codeNo  = $('#codeNo'+ids).val();
        var codeNo = $('#selecteds').val();
        var content = $('#content').val();
        if (content == "") {
          alert('短信内容必填');
          return false;
        }
        
        $.ajax({
          url:"__URL__/duanxin",
          type:'post',
          cache:false,
          dataType:'JSON',
          timeout: 10000,
          data:{"user_id":user_id,"mobile":mobile,"codeNo":codeNo,"content":content},
          success:function(data){
            // console.log(data);
              if (data.code == 1) {
                alert('发送成功');
                $('.dialogbox').hide();
                window.location.reload();
              }
              if (data.code == 0) {
                alert('发送失败');
                // window.location.reload();
              }
              if (data.code == 5) {
                alert('手机号码不存在');
                // window.location.reload();
              }
              if (data.code == 6) {
                alert('短信条数不足');
                // window.location.reload();
              }
              if (data.code == 7) {
                alert('目的码不存在');
                // window.location.reload();
              }
              
          }
      }) 
      }

      function outbiao(){
        var kauser = $('#kauser').val();
        if (kauser == 'fen' || kauser == '') {
          alert('请选择下级用户');return false;
        }
        location.href = "__URL__/outexcel?kauser="+kauser;
      }

</script>